package com.wanxi.web.controller;

import com.wanxi.product.service.api.query.admin.TypeQuery;
import com.wanxi.product.service.api.query.enterprise.SkuQuery;
import com.wanxi.product.service.api.query.enterprise.SpuQuery;
import com.wanxi.product.service.api.result.CommonResult;
import com.wanxi.product.service.api.vo.enterprise.TypeAddInVo;
import com.wanxi.product.service.api.vo.enterprise.TypeFindAllOutVo;
import com.wanxi.product.service.api.vo.enterprise.TypeUpdateInVo;
import com.wanxi.product.service.api.vo.enterprise.*;
import com.wanxi.repertory.service.api.vo.RepertoryTotalAllocateInVo;
import com.wanxi.web.service.product.ProductEnterpriseWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: enterpriseProductController
 * Description: 商家产品
 * date: 2022/1/13 14:31
 *
 * @author lxl
 * @version 1.0
 * @since JDK 1.8
 */
@Api(tags = "商家商品接口")
@RestController
@RequestMapping("enterprises")
public class EnterpriseProductController {
    @Resource
    private ProductEnterpriseWebService productWebService;

    /**
     * *********************** 商品分类********************
     * */
    @ApiOperation("添加三级分类")
    @PostMapping("/type/add")
    public CommonResult<Long> addType(TypeAddInVo typeAddInVo) {
        return productWebService.addType(typeAddInVo);
    }

    @ApiOperation("获取三级分类列表")
    @GetMapping("/type/findAll")
    public CommonResult<List<TypeFindAllOutVo>> findAllType(TypeQuery typeQuery) {
        return productWebService.findAllType(typeQuery);
    }

    @ApiOperation("根据id查询分类")
    @GetMapping("/types/findById")
    public CommonResult<TypeFindByIdOutVo> findTypeById(Long id) {
        return productWebService.findTypeById(id);
    }

    @ApiOperation("修改三级分类")
    @PutMapping("/types/update")
    public CommonResult updateType(TypeUpdateInVo typeUpdateInVo) {
        return productWebService.updateType(typeUpdateInVo);
    }

    @ApiOperation("逻辑删除三级分类")
    @PutMapping("/types/delete")
    public CommonResult deleteTypeById(Long id) {
        return productWebService.deleteTypeById(id);
    }

    /**
     * **************************Spu********************
    * */

    @ApiOperation("添加spu")
    @PostMapping("/spu/add")
    public CommonResult<Long> addSpu(SpuAddInVo spuAddInVo) {
        return productWebService.addSpu(spuAddInVo);
    }

    @ApiOperation("按条件查找SPU")
    @GetMapping("/spu/findAll")
    public CommonResult<List<SpuFindAllOutVo>> findAllSpu(SpuQuery spuQuery) {
        return productWebService.findAllSpu(spuQuery);
    }

    @ApiOperation("根据id查询SPU")
    @GetMapping("/spu/findById")
    public CommonResult<SpuFindByIdOutVo> findSpuById(SpuFindByIdInVo spuFindByIdInVo) {
        return productWebService.findSpuById(spuFindByIdInVo);
    }

    @ApiOperation("修改spu")
    @PutMapping("/spu/update")
    public CommonResult updateSpu(SpuUpdateInVo spuUpdateInVo) {
        return productWebService.updateSpu(spuUpdateInVo);
    }

    @ApiOperation("逻辑删除spu")
    @PutMapping("/spu/delete")
    public CommonResult deleteSpu(SpuDeleteInVo spuDeleteInVo) {
        return productWebService.deleteSpu(spuDeleteInVo);
    }


    /**
    * *****************************sku****************************
    * */

    @ApiOperation("添加sku")
    @PostMapping("/sku/add")
    public CommonResult<Long> addSku(SkuAddInVo skuAddInVo) {
        return productWebService.addSku(skuAddInVo);
    }

    @ApiOperation("获取sku列表")
    @GetMapping("/sku/findAll")
    public CommonResult<List<SkuFindAllOutVo>> findAllSku(SkuQuery skuQuery) {
        return productWebService.findAllSku(skuQuery);
    }

    @ApiOperation("根据id查找sku")
    @GetMapping("/sku/findById")
    public CommonResult<SkuFindByIdOutVo> findSkuById(Long id) {
        return productWebService.findSkuById(id);
    }

    @ApiOperation("修改sku")
    @PutMapping("/sku/update")
    public CommonResult updateSku(SkuUpdateInVo skuUpdateInVo) {
        return productWebService.updateSku(skuUpdateInVo);
    }

    @ApiOperation("删除sku")
    @PutMapping("/sku/delete")
    public CommonResult deleteSkuById(Long id) {
        return productWebService.deleteSkuById(id);
    }

    /**
     * ****************************库存****************************
     * */

    @ApiOperation("分配库存")
    @PutMapping("/repertory/total/allocate")
    public com.wanxi.repertory.service.api.result.CommonResult allocate(RepertoryTotalAllocateInVo skuAllocateInVo){
        return productWebService.allocate(skuAllocateInVo);
    }
}
